package com.qf.qa.service.impl;

import com.qf.qa.entity.Questions;
import com.qf.qa.mapper.QuestionsMapper;
import com.qf.qa.service.QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author songfei
 * @Date 2021/10/7 16:46
 * @Version 1.0
 */
@Service
public class QuestionsServiceImpl implements QuestionsService {
    @Autowired
    private QuestionsMapper questionsMapper;
    @Override
    public void insert(Questions questions) {
        int i = questionsMapper.insertSelective(questions);
        if(i!=1){
            System.out.println("添加问题失败");
            throw new RuntimeException("添加问题失败");
        }
    }

    @Override
    public void update(Integer id) {
        int i = questionsMapper.updateById(id);
        if(i!=1){
            System.out.println("修改回答问题失败");
            throw new RuntimeException("修改回答问题失败");
        }
    }

    @Override
    public Questions findByQuestionIdAll(Integer id) {
        return questionsMapper.findByQuestionIdAll(id);
    }
}
